<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    protected string $tableName = 'admin_menu';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->tableName)) {
            return;
        }
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->comment('后台菜单表');
            $table->increments('id')->comment('主键ID');
            $table->integer('created_id')->default(0)->comment('');
            $table->integer('created_at')->default(0)->comment('');
            $table->integer('updated_id')->default(0)->comment('');
            $table->integer('updated_at')->default(0)->comment('');
            $table->integer('deleted_id')->default(0)->nullable()->comment('');
            $table->integer('deleted_at')->default(0)->nullable()->comment('');
            $table->integer('parent_id')->default(0)->comment('上级ID');
            $table->string('name', 80)->default('')->comment('名称');
            $table->string('app', 15)->default('')->nullable()->comment('应用名');
            $table->string('controller', 30)->default('')->nullable()->comment('控制器名');
            $table->string('action', 100)->default('')->nullable()->comment('操作名');
            $table->string('route', 100)->default('')->nullable()->comment('路由');
            $table->string('icon', 60)->default('')->nullable()->comment('图标');
            $table->tinyInteger('type')->default(1)->nullable()->comment('类型 1=模块 2=列表 3=操作');
            $table->string('target', 20)->default('')->nullable()->comment('跳转方式');
            $table->string('remark', 255)->default('')->nullable()->comment('备注');
            $table->integer('sorting')->default(0)->nullable()->comment('');
            $table->tinyInteger('status')->default(0)->comment('状态 1-显示 2-不显示');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
};
